package models
{
	import flash.utils.Dictionary;

	public class TweenCounter
	{
		private var counterDic:Dictionary=new Dictionary();
		public function TweenCounter()
		{
		
		}
		
		public function addCounter(name:String):void{
			if(counterDic[name]){
				counterDic[name]++;
			}else{
				var counter:int=1;
				counterDic[name]=counter;
			}
		}
		public function subCounter(name:String,completefun:Function):void{
			counterDic[name]--;
			if(counterDic[name]<=0){
				completefun();
			}
		}
		//*****************************************************
		// Singleton 
		//*****************************************************
		private static var _instant:TweenCounter;
		public static function get instant():TweenCounter
		{
			if(null == _instant)
			{
				_instant =  new TweenCounter();
			}
			return _instant;
		}
	}
}